﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">

  
  <!-- Property placeholder configurer for database settings -->
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <!-- Database and NHibernate Configuration -->
  <db:provider id="DbProvider"
					 provider="SqlServer-2.0"
					 connectionString="Data Source=${db.datasource};Database=${db.database};User ID=${db.user};Password=${db.password};"/>


  <object id="SessionFactory" type="TinyERP.Framework.LocalSessionFactoryObjectImp, TinyERP.Framework">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="HibernateProperties">
      <dictionary>

        <entry key="connection.provider"
					   value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="show_sql" value="false"/>
        <entry key="dialect"
					   value="NHibernate.Dialect.MsSql2005Dialect"/>

        <entry key="connection.driver_class"
					   value="NHibernate.Driver.SqlClientDriver"/>
        <entry key="query.substitutions"
						value="true 1, false 0, yes 'Y', no 'N'"/>
        <entry key="use_outer_join"	value="true"/>
        <entry key="default_schema"	value="TinyERP.dbo"/>
        <entry key="hibernate.hbm2ddl.auto" value="create"></entry>
      </dictionary>
    </property>

  </object>


  <object id="HibernateTransactionManager"
		  type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate20">

    <property name="DbProvider" ref="DbProvider"/>
    <property name="SessionFactory" ref="SessionFactory"/>

  </object>

  <object id="HibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate, Spring.Data.NHibernate20">
    <property name="SessionFactory" ref="SessionFactory" />
    <property name="TemplateFlushMode" value="Auto" />
    <property name="CacheQueries" value="true" />
  </object>

  <object id="TxProxyConfigurationTemplate" abstract="true"
			   type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">

    <property name="PlatformTransactionManager" ref="HibernateTransactionManager"/>
    <property name="TransactionAttributes">
      <name-values>
        <add key="Get*" value="PROPAGATION_REQUIRED"/>
        <add key="Search*" value="PROPAGATION_REQUIRED"/>
        <add key="Save*" value="PROPAGATION_REQUIRED"/>
        <add key="Update*" value="PROPAGATION_REQUIRED"/>
        <add key="Delete*" value="PROPAGATION_REQUIRED"/>
        <add key="Assign*" value="PROPAGATION_REQUIRED"/>
        <add key="Create*" value="PROPAGATION_REQUIRED"/>
        <add key="RegisterUser*" value="PROPAGATION_REQUIRED"/>

      </name-values>
    </property>
  </object>
</objects>
